import {api} from './utils/api';
import getUrl from './utils/getUrl'
// app.js
App({
  onLaunch() {
    this.api = api;
    this.getUrl = getUrl;
    this.app_id = 'wx6a78a7b16fa9ed9c';
    wx.login({
      success:(res)=>{
        const data = {
          code:res.code,
          app_id:this.app_id
        }
        console.log(res.code)

        this.api.post(this.getUrl('login'), data).then((res)=>{
          console.log(res)
          wx.setStorageSync('token', res.data.access_token)
        })
      }
    })
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null,
  }
})
